package com.sfpay.merchant.auth.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.sfpay.merchant.auth.entity.system.SysOperLog;
import com.sfpay.merchant.common.utils.AddressUtils;
import com.sfpay.merchant.common.utils.spring.SpringUtils;


import java.util.List;
import java.util.TimerTask;

/**
 * <p>
 * 操作日志记录 服务类
 * </p>
 *
 * @author fangchen
 * @since 2022-07-14
 */
public interface ISysOperLogService extends IService<SysOperLog> {

    /**
     * 操作日志记录
     *
     * @param operLog
     * @return
     */
    public static TimerTask recordOper(final SysOperLog operLog) {
        return new TimerTask() {
            @Override
            public void run() {
                // 远程查询操作地点
                operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
                SpringUtils.getBean(ISysOperLogService.class).save(operLog);
            }
        };
    }


    List<SysOperLog> selectOperLogList(SysOperLog operLog);

    int deleteOperLogByIds(String ids);

    /**
     * 查询操作日志详细
     *
     * @param operId 操作ID
     * @return 操作日志对象
     */
    SysOperLog selectOperLogById(Long operId);

    void cleanOperLog();
}
